package cn.jizi.bshisy.service.impl;

import cn.jizi.bshisy.entity.Drug;
import cn.jizi.bshisy.mapper.DrugMapper;
import cn.jizi.bshisy.service.DrugService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 李鹏辉Code
 * @create 2020 -10 -31 13:59
 */
@Service
public class DrugServiceImpl implements DrugService {

    @Resource
    private DrugMapper drugMapper;

    @Transactional
    @Override
    public boolean drugDelivery(String did, Integer num) {
        //标识
        boolean mark = false;
        if (drugMapper.drugDelivery(did, num) > 0)
            mark = true;//出库数据库更新成功
        return mark;
    }

    @Transactional
    @Override
    public boolean drugWarehouse(Drug drug, Integer newNum) {
        //以有药品的入库 更新原有的药品的数量等等
        //标识
        boolean mark = false;
        if (drugMapper.drugWarehouse(drug, newNum) > 0)
            mark = true;//入库更新成功
        return mark;
    }

    @Transactional
    @Override
    public boolean newDrugs(Drug drug) {
        //新药品入库
        boolean mark = false;
        if (drugMapper.newDrugs(drug) > 0)
            mark = true;//新药品入库插入成功
        return mark;
    }

    @Override
    public List<Drug> findByNum() {
        return drugMapper.findByNum();
    }
}
